﻿using System.Runtime.Serialization;
using CID.Domain.Infrastructure;

namespace CID.Execution.Support.Information
{
    [DataContract]
    public class TemplateInfo
    {
        internal TemplateInfo() { }

        public TemplateInfo(ITemplate template) : this()
        {
            Type = new TemplateTypeInfo(template.Type);
            Id = template.Id;
            Name = template.Name;
            MultipleServersSupport = template.MultipleServersSupport;
            Content = template.Content;
        }

        [DataMember]
        public int Id { get; set; }

        [DataMember]
        public TemplateTypeInfo Type { get; set; }

        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public bool MultipleServersSupport { get; set; }

        [DataMember]
        public byte[] Content { get; set; }

        internal TemplateInfo Clone()
        {
            return new TemplateInfo() { Id = Id, Name = Name, MultipleServersSupport = MultipleServersSupport, Content = (byte[])Content.Clone(), Type = Type.Clone() };
        }
    }
}
